package com.shopnight.controller.errand;


import com.shopnight.entity.ErrandOrder;
import com.shopnight.result.ApiResult;
import com.shopnight.service.ErrandOrderService;
import com.shopnight.vo.ErrandInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/token")
@Api(tags = {"ErrandOrderController"},description = "跑腿业务所需接口")
public class  ErrandOrderController {

    @Autowired
    ErrandOrderService errandOrderService;

    @PostMapping("/addErrandOrder")
    @ApiOperation(value = "添加跑腿订单", notes = "")
    public ApiResult addErrandOrder(@ApiParam("") @RequestBody ErrandOrder errandOrder) throws Exception {
        return ApiResult.ok(errandOrderService.addErrandOrder(errandOrder));
    }

    @GetMapping("/getErrandOrderInfo")
    @ApiOperation(value = "获取跑腿订单详情信息", notes = "")
    public ApiResult<ErrandInfoVo> getErrandOrderInfo(@RequestParam Integer errandId)  {
        return ApiResult.ok(errandOrderService.getErrandOrderInfo(errandId));
    }

    @GetMapping("/cancelErrandOrder")
    @ApiOperation(value = "取消跑腿订单", notes = "")
    public ApiResult cancelErrandOrder(@RequestParam Integer id)  {
        return errandOrderService.cancelErrandOrder(id);
    }

}
